const pool = require('../config/db');

/**
 * 分类模型
 */
const Category = {
  /**
   * 查询所有分类
   */
  findAll: async () => {
    const [rows] = await pool.query(
      'SELECT category_id, category_name FROM categories ORDER BY category_id'
    );
    
    return rows.map(row => ({
      categoryId: row.category_id,
      categoryName: row.category_name
    }));
  }
};

module.exports = Category;